# 使用 cmake -P main.cmake 执行对应.cmake文件
cmake_minimum_required(VERSION 3.20)

function(foo first_arg)
    # 1、打印函数名称
    message("runing function name is " ${CMAKE_CURRENT_FUNCTION})
    message("first_arg is " ${first_arg})

    message("第一个参数是 " ${ARGV0})
    message("第二个参数是 " ${ARGV1})
    message("第三个参数是 " ${ARGV2})

endfunction()

set(arg some_arg)

# 函数传参：引用变量和直接写不一样
foo(${arg})
foo(arg)
foo(arg 1 2)

# 支持函数内嵌套
function(bar)
    message("runing function name is " ${CMAKE_CURRENT_FUNCTION})
    function(gkd)
        message("runing function name is " ${CMAKE_CURRENT_FUNCTION})
    endfunction()
    gkd()
endfunction()
bar()
